<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>样式转换</title>
    <style>
        .box {
            height: 500px;
            width: 500px;
            background-color: #000;
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <button class="show">显示</button>
    <button class="hidden">隐藏</button>
    <button class="change">显示/隐藏</button>

    <script>
        let boxEle = document.querySelector('.box')
        let showEle = document.querySelector('.show')
        let hiddenEle = document.querySelector('.hidden')
        let changeEle = document.querySelector('.change')
        let isShow = true

        hiddenEle.addEventListener('click', function () {
            boxEle.style.display = 'none'
            isShow = false 
        })

        showEle.addEventListener('click', function () {
            boxEle.style.display = ''
            isShow = true
        })

        changeEle.addEventListener('click', function () {
            if (isShow) {
                boxEle.style.display = 'none'
                isShow = false
            } else {
                boxEle.style.display = ''
                isShow = true
            }
        })


    </script>
</body>
</html>